//
//  LLUserHandle.m
//  UserUse
//
//  Created by Yiwi on 16/10/25.
//  Copyright © 2016年 CJPC. All rights reserved.
//

#import "LLUserHandle.h"

NSString * const userPath = @"Documents/savePeople";

@implementation LLUserHandle

+(void)saveUserDataWith:(LLUserModel*)user{
    NSData * data = [NSKeyedArchiver archivedDataWithRootObject:user];
    [data writeToFile:[NSHomeDirectory() stringByAppendingPathComponent:userPath] atomically:YES];
    NSLog(@"沙盒路径：%@",[NSHomeDirectory() stringByAppendingPathComponent:userPath]);
}
+(LLUserModel *)getUserData{
    NSData * data = [NSData dataWithContentsOfFile:[NSHomeDirectory() stringByAppendingPathComponent:userPath]];
    return [NSKeyedUnarchiver unarchiveObjectWithData:data];
}
+(void)clearUserData{
    NSFileManager * fileManager = [[NSFileManager alloc]init];
    [fileManager removeItemAtPath:[NSHomeDirectory() stringByAppendingPathComponent:userPath] error:nil];
    NSLog(@"沙盒路径：%@",[NSHomeDirectory() stringByAppendingPathComponent:userPath]);

}

@end
